package com.atguigu.rulepo;

import org.jeasy.rules.annotation.Rule;
import org.jeasy.rules.annotation.Condition;
import org.jeasy.rules.annotation.Fact;
import org.jeasy.rules.annotation.Action;
import org.jeasy.rules.annotation.Priority;

//该注解表示规则
@Rule
public class CutTenRule {

    private Integer price;

    // 该注解标记为条件
    @Condition
    public boolean isLowerThan200(@Fact("price") Integer price) {
        this.price = price;
//        return price < 200;//1
//        return price <= 200;//2
        return price <= 200;//3
    }

    // 该注解表示条件判断之后的操作
    @Action
    public void printPriceAfterDiscount() {
        System.out.println("折扣规则为减10元原价为:"+price+"折扣后价格的价格为：" + (price > 10 ? price - 10 : price));
    }

    //该注解表示优先级
    @Priority
    public int getPriority() {
        return 0;
    }

}
